package cn.itcast.mq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TTLMessageConfig {
    @Bean
    public DirectExchange ttlDirectExchange(){
        return new DirectExchange("art415.ttl.direct");
    }
    @Bean
    public Queue ttlQueue(){
        return QueueBuilder
                .durable("art415.ttl.queue")
                //.ttl(10000)  一般不在队列设置
                .deadLetterExchange("art415.dl.direct")
                .deadLetterRoutingKey("art415.dl")
                .build();
    }
    @Bean
    public Binding ttlBinding(Queue ttlQueue, DirectExchange ttlDirectExchange){
        return BindingBuilder.bind(ttlQueue).
                to(ttlDirectExchange).with("art415.ttl");
    }
}
